//Display image information of bmp file
//imfinfo('lena.bmp')


#include<stdio.h>


typedef struct bmpimage
{
unsigned short bfType;	//file header type
unsigned long bfSize;		//size of bmp file
unsigned short bfReserved1;	//Reserved
unsigned short bfReserved2;	//Reserved
unsigned long Offset;		//Offset value , starting address
unsigned long biSize;		//size of this header
unsigned long biWidth;	//bitmap width in pixel
unsigned long biHeight;	//bitmap height in pixel
unsigned short plane;		//number of color of planes
unsigned short count;		//number of bits per pixel
unsigned long compression;	//compression being used
unsigned long SizeImage;	//image size
unsigned long XpelperMeter;	//horizontal resolution of image
unsigned long YpelperMeter;	//vertical resolution of the image
unsigned long ClrUsed;	//number of colors in color palette
unsigned long ImportantClr;	//number of imp colors used
}bmpimage;

void main()
{
   bmpimage Header;

   FILE *fp;
   char image[20];
   //clrscr();

   printf("Enter the name of BMP image:");

   gets(image);   	//gets the image file and stores in �image�

   fp=fopen(image,"r");  //opens the image in  read mode

   if(fp==NULL)
   {
       printf("ERROR! Could not open image");
   }

   else
   {

    fread(&Header,sizeof(Header),1,fp);

    printf("bfType= 	  %c\n",Header.bfType);
    printf("bfSize= 	  %ld\n",Header.bfSize);
    printf("bfReserved1=       %d\n",Header.bfReserved1);
    printf("bfReserved2=       %d\n",Header.bfReserved2);
    printf("Offset= 	 %d\n",Header.Offset);
    printf("biSize= 	 %d\n",Header.biSize);
    printf("biWidth=	%d\n",Header.biWidth);
    printf("biHeight=	%d\n",Header.biHeight);
    printf("plane= 	 %d\n",Header.plane);
    printf("count=     %d\n",Header.count);
    printf("compression=	%d\n",Header.compression);
    printf("SizeImage= %d\n",Header.SizeImage);
    printf("XpelperMeter=	%d\n",Header.XpelperMeter);
    printf("YpelperMeter=	%d\n",Header.YpelperMeter);
    printf("ClrUsed=	%d\n",Header.ClrUsed);
    printf("ImportantClr=     %d\n",Header.ImportantClr);

    }
getch();
}